<%@page import="com.wanmait.movies.vo.Collect"%>
<%@page import="com.wanmait.movies.vo.Movie"%>
<%@page import="java.util.ArrayList"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%
String path=request.getContextPath();
%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="<%=path %>/js/jquery-3.5.1.min.js"></script>
<script type="text/javascript">
$(function () {
	$("#ThisPage").blur(function(){//这是text查找页数的
		var thispage=$("#ThisPage").val();
		var pagemax=$("#NextPage").attr("pagemax");
		if(thispage>pagemax){
			thispage=pagemax;
			$("#ThisPage").val(pagemax);
		}else{
			location.href="<%=path%>/UserServlet?action=collect&thispage="+thispage;
		}
		
	});
});
$(function () {
	$("#LastPage").click(function(){//上一页
		//alert("11654");
		var thispage=$("#ThisPage").val();
		thispage--;
		if(thispage<1){
			thispage=1;
		}else{
			location.href="<%=path%>/UserServlet?action=collect&thispage="+thispage;
		}
	});
});
$(function () {
	$("#NextPage").click(function(){//下一页
		var thispage=$("#ThisPage").val();
		var pagemax=$("#NextPage").attr("pagemax");
		      thispage++;
		    //  alert(pagemax);
		if(thispage>pagemax){
			thispage=pagemax;
		}else{
			location.href="<%=path%>/UserServlet?action=collect&thispage="+thispage;
		}
		});
});
$(function () {//每一部收藏后面跟的取消收藏
	$(".Cancellation").on("click",function () {
		var collectid=$(this).attr("gid");
		var temp = $(this);
		$.ajax({
         url:"<%=path%>/UserServlet",
         type:"get",
         data:{action:"collectdelete",collectid:collectid},
         success:function (mes){
        	 temp.parent().parent().parent().parent().remove();
         }
		});
	});
	
});
$(function () {//全选框 点中全选
	$("#size").on("click","#allcollect",function(){
		var flag=$("#allcollect").prop("checked");
		if(flag==true){
			$(".collects").prop("checked",true);
		}else{
			$(".collects").prop("checked",false);
		}
		 
	});
});
$(function () {
	$("#alldelete").click(function(){//批量取消收藏 
	//	alert("21131");
		var cks= $(".collects:checked");
		var str="";
		cks.each(function(){
			var gid=$(this).attr("gid");
			str=str+","+gid;
			$(this).parent().parent().parent().remove();//父类div div的父类list
		});
		str=str.substring(1);
		if(str!=""){
			$.ajax({
		         url:"<%=path%>/UserServlet",
		         type:"get",
		         data:{action:"collectdelete",collectid:str},
		         success:function (mes){
		        	 $("#alldelete").prop("checked",false);
		         }
				});
			} else{
			$(".Tips").html("请勾选收藏");
		}
	});
})
</script>
<style type="text/css">
#size{
width:800px;
height:530px;
margin: auto;
text-align: center;
border:1px solid black;
overflow: auto;
}
a:link,a:visited{ 
 text-decoration:none;  /*超链接无下划线*/ 
} 
.list{
width:198px;
height:100px;
float: left;

}
.list div{
width:80px;
height:20px;
float: left;
padding-top:5px; 
}
#fenye{
width:800px;
height:100px;
text-align: center;
margin: auto;
}
img{
height:70px;
}
img:hover{
height:90px;
}
#quanxuan{
width:300px;
height:20px;
text-align: left;
padding-left: 30px;
}
#ThisPage{
width:30px;
}
.listsize{
width:798px;
height:100px;
border:solid 1px black;
margin:auto; 
}
.listnext{
width:500px;
height:50px;
float: left;
}
.listnextnext{
width:698px;
height:50px;
float: left;
}
.listnextnext div{
width:80px;
height:50px;
line-height:50xp; 
float: left;
}
.listnextsize{
overflow: hidden;
width:500px;
height:50px;
}
</style>
</head>
<body>
<div id="size"> <!-- 最大div -->
<div id="quanxuan"><input type="checkbox" id="allcollect" /><a id="alldelete" href="javascript:">取消收藏</a><span class="Tips"></span></div>
<%
ArrayList<Collect>allcollect=(ArrayList<Collect>)request.getAttribute("allcollect");
for(Collect collect:allcollect){
%>
<div class="listsize"><!-- 每一行就是一部电影的div -->
<div class="list"><!-- 将收藏的电影列出来  缩略图和复选框的div-->
<div><input type="checkbox" class="collects" gid="<%=collect.getId() %>" /></div>
<div><a href="javascript:"><img src="<%=path %>/images/<%=collect.getMovieId().getMovieImage() %>"/></a></div>
</div>
<div class="listnext"><!-- 电影信息的div和电影简介div -->
<div class="listnextnext"><!-- 电影信息div -->
<div><a href="javascript:"><%=collect.getMovieId().getMovieName() %></a></div>
<div><a href="javascript:"><%=collect.getMovieId().getMovieTime() %>分钟</a></div>
<div><a href="javascript:"><%=collect.getMovieId().getMovieTypeId().getMovieType() %></a></div>
<div><a href="javascript:"><%=collect.getMovieId().getMovieLanguageId().getLanguageType() %></a></div>
<div><a href="javascript:"><%=collect.getMovieId().getMovieCountryId().getCountry() %></a></div>
<div><a href="javascript:" class="Cancellation" gid="<%=collect.getId() %>">取消收藏</a></div>
</div>
<div class="listnextsize"><!-- 电影简介  点击更多直接跳转影片网页 -->
<%=collect.getMovieId().getMovieIntroduction() %><a href="javascript:">&gt;&gt;更多</a>
</div>
</div>
</div>
<%
}
%>
</div>
<div id="fenye"><!-- 分页查询 -->
<a href="javascript:" id="LastPage">上一页</a>
<input id="ThisPage"  type="text" value="<%=request.getAttribute("ThisPage") %>" />
<a href="javascript:" id="NextPage" pagemax="<%=request.getAttribute("pagemax")%>">下一页</a>
</div>
</body>
</html>